/**
 * Definition for singly-linked list.
 * function ListNode(val, next) {
 *     this.val = (val===undefined ? 0 : val)
 *     this.next = (next===undefined ? null : next)
 * }
 * 输入：head = [1,1,2,3,3]
 输出：[1,2,3]
 */

/**
 * @param {ListNode} head
 * @return {ListNode}
 */
var hasCycle = function(head) {
    if(head === null || head.next === null){
        return  false;
    }
    let slow = head;
    let quick = head.next;
    while (slow !== quick){
        if(quick === null || quick.next === null ){
            return false
        }
        quick = quick.next.next;
        slow = slow.next;
    }
    return true;
};
